package com.lj.file.service;

import com.lj.file.entity.FilePartDetail;
import com.lj.mp.standard.StandardService;

import java.util.List;

/**
 * <p>
 * 文件分片信息表 服务类
 * </p>
 *
 * @author lj
 * @since 2025-07-04 16:10:50
 */
public interface FilePartDetailService extends StandardService<FilePartDetail> {


    default void deleteFilePartByUploadId(String uploadId) {
        remove(lambdaQueryWrapper().eq(FilePartDetail::getUploadId, uploadId));
    }

    default FilePartDetail getPart(String uploadId, Integer partNumber) {
        return getOne(lambdaQueryWrapper()
                .eq(FilePartDetail::getUploadId, uploadId)
                .eq(FilePartDetail::getPartNumber, partNumber)
                .last("limit 1"));
    }

    default List<FilePartDetail> getParts(String uploadId) {
        return list(lambdaQueryWrapper()
                .eq(FilePartDetail::getUploadId, uploadId));
    }

}
